#ifndef CANIMATIONENGINE_H_
#define CANIMATIONENGINE_H_
#include <vector>
#include "CTextureManager.h"
using std::vector;

enum states
{
	Gothic_Idle,
	Gothic_Jump,
Gothic_Walk,   
Greek_Idle, 
Greek_Jump,
Greek_Walk, 
MidEvil_Idle, 
MidEvil_Jump, 
MidEvil_Walk, 
Shocked	,
Cloud_Eat,
Cloud_Idle,
Cloud_Lightning,
Cloud_LightningBolt,
Sun_Idle
};
struct Frame
{
	Texture		   *m_pTexHandle;
	float			m_fFrameTime;
};

struct Animation
{
	char			m_szFileName[56];
	float			m_fCurrTime;
	unsigned int	m_unCurrFrame;
	vector<Frame>	m_FrameList;

	Animation()
	{
		m_fCurrTime = 0;
		m_unCurrFrame = 0;
	}

	Texture *GetCurrentTextureHandle()
	{
		return m_FrameList[m_unCurrFrame].m_pTexHandle;
	}

	bool Play(float fElapsed)				// Returns false when the animation has completed
	{
		m_fCurrTime += fElapsed;
		if (m_fCurrTime >= m_FrameList[m_unCurrFrame].m_fFrameTime)
		{
			m_fCurrTime -= m_FrameList[m_unCurrFrame].m_fFrameTime;
			m_unCurrFrame++;
			if (m_unCurrFrame >= m_FrameList.size())
			{
				m_unCurrFrame = 0;
				return false;
			}
		}
		return true;
	}
};

class CAnimationEngine
{
private:
	struct FileHeader
	{
		char szFileName[56];
		int	 nFileOffset;
		int	 nFileLength;
	};

public:
	vector<Animation*>	m_vAnimations;

	static CAnimationEngine *GetInstance();

	Animation *LoadAnimation(int State);

	bool LoadAllAnimations();

	void Shutdown();
};

#endif